package com.yh.services.impl;

import com.yh.dao.UserMapper;
import com.yh.entity.User;
import com.yh.services.IUserService;
import com.yh.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class UserServiceImpl implements IUserService {
    SqlSession sqlSession=SqlSessionFactoryUtil.getSqlSession();
    UserMapper mapper = sqlSession.getMapper(UserMapper.class);


    @Override
    public User login(User user) {
        return mapper.login(user);
    }

    @Override
    public List<User> showAll() {
        return mapper.showAll();
    }

    @Override
    public int delUser(User user) {
     int b=mapper.delUser(user);
        sqlSession.commit();
        return b;

    }

    @Override
    public User getUserByIud(User user) {
        return mapper.getUserByIud(user);
    }

    @Override
    public int updUser(User user) {
        int b=mapper.updUser(user);
        sqlSession.commit();
        return b;
    }

    @Override
    public int addUser(User user) {
        int b=mapper.addUser(user);
        sqlSession.commit();
        return b;
    }
}
